package com.mconnect.msurvey.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
/**
 * Kampanie (plany ankiet)
 * @author mc104910
 *
 */
@Entity
@Table(name = "survey_plan")
public class SurveyPlan implements Serializable{
	private static final long serialVersionUID = 5161180988491258299L;
	private int id_plan;
	private String planName;
	private int goal = -1;
	private int days = -1;
	private int hours = -1;
	private String typeOfSurvey;
	private int usersNumber;
	private Date createDate;
	private Date endDate;
	private String status = "w trakcie";
	private List<User> users;
	private PriceList id_price;
	
	@Id
	@GeneratedValue
	public int getId_plan() {
		return id_plan;
	}
	public void setId_plan(int id_plan) {
		this.id_plan = id_plan;
	}
	@Column(length=30)
	public String getPlanName() {
		return planName;
	}
	public void setPlanName(String planName) {
		this.planName = planName;
	}
	@Column(length=10)
	public int getGoal() {
		return goal;
	}
	public void setGoal(int goal) {
		if(goal > 0)
			this.goal = goal;
	}
	@Column(length=10)
	public int getDays() {
		return days;
	}
	public void setDays(int days) {
		if(days > 0)
			this.days = days;
	}
	@Column(length=10)
	public int getHours() {
		return hours;
	}
	public void setHours(int hours) {
		if(hours > 0)
			this.hours = hours;
	}
	@Column(length=20)
	public String getTypeOfSurvey() {
		return typeOfSurvey;
	}
	public void setTypeOfSurvey(String typeOfSurvey) {
		this.typeOfSurvey = typeOfSurvey;
	}
	@Column(length=20)
	public String getStatus() {
		return status;
	}
	@ManyToMany(cascade={CascadeType.ALL})
	public List<User> getUsers() {
		return users;
	}
	public void setUsers(List<User> users) {
		this.users = users;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	@Column(length=10)
	public int getUsersNumber() {
		return usersNumber;
	}
	public void setUsersNumber(int usersNumber) {
		this.usersNumber = usersNumber;
	}
	@Temporal(TemporalType.TIMESTAMP)
	public Date getCreateDate() {
		return createDate;
	}
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	@Temporal(TemporalType.TIMESTAMP)
	public Date getEndDate() {
		return endDate;
	}
	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}
	
	@OneToOne(targetEntity=PriceList.class, cascade = CascadeType.ALL, fetch=FetchType.LAZY)
    @JoinColumn(name = "id_price", referencedColumnName="id_price" )
	@Fetch(FetchMode.SELECT)
	public PriceList getId_price() {
		return id_price;
	}
	public void setId_price(PriceList id_price) {
		this.id_price = id_price;
	}
	@Override
	public String toString() {
		return "SurveyPlan [id_plan=" + id_plan + ", planName=" + planName
				+ ", goal=" + goal + ", days=" + days + ", hours=" + hours
				+ ", typeOfSurvey=" + typeOfSurvey + ", usersNumber="
				+ usersNumber + ", createDate=" + createDate + ", endDate="
				+ endDate + ", status=" + status + ", id_price=" + id_price
				+ "]";
	}
	
	
	
	
	

}
